﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AffinityORMLibrary.DataTypes;
using AffinityORMLibrary.DataLayer.Action;
using AffinityORMLibrary.DataLayer.Assembler;
using AffinityORMLibrary.DataLayer.Factory;
using AffinityORMLibrary.DataLayer.Utility;
using System.Configuration;

namespace AffinityORMLibrary.DataLayer.Factory
{
    class SysTableColumnFactory : Factory.FactoryBase<SysTableColumn>
    {
        public SysTableColumnFactory(ConnectionStringSettings connectionString)
            : base(connectionString)
        {

        }

        public List<SysTableColumn> GetSysTableColumns(SysTableInfo table)
        {
            List<SysTableColumn> result;
            ISelectionAction action = new GetSysTableColumns();
            SysTableColumn domain = new SysTableColumn();
            domain.SetCriteria(typeof(SysTableColumn).GetProperty("TABLE_NAME"), table.TABLE_NAME, SelectionCriteriaComparer.Equals);
            IAssembler<SysTableColumn> assembler = new SysTableColumnAssembler();

            try
            {
                result = this.Find(domain, assembler, action);
            }
            catch
            {
                result = new List<SysTableColumn>();
            }

            return result;
        }
    }
}
